//
//  MemoryTests.m
//  Memento 2.0
//
//  Created by Chris Maddocks on 2010-07-04.
//  Copyright 2010 Team Memento. All rights reserved.
//
//  10-07-21: Bump version in header to 2.0.  (C. Maddocks)

#import "MemoryTests.h"
#import "Memory.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>


@implementation MemoryTests


- (void) testMath {
    
	STAssertTrue((1+1)==2, @"Compiler isn't feeling well today :-(" );

}


- (void) helpTestMemoryWithId:(int)memoryId 
				imageFile:(NSString *)imageFile
				audioFile:(NSString *)audioFile
					 date:(NSDate *)date
					  lat:(double)lat
				      lng:(double)lng 
{
	Memory *memory = [[[Memory alloc] initWithDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
														  [NSNumber numberWithInt:memoryId], kMemoryId,
														  imageFile, kImagePath,
														  audioFile, @"AudioPath", //kAudioPath,
														  date, kDateTime,
														  [NSNumber numberWithDouble:lat], kLatitude,
														  [NSNumber numberWithDouble:lng], kLongitude, 
														  nil]] retain];	 
	STAssertTrue( [memory memoryId], @"Memory ID did not match" );
	STAssertTrue( [[memory dateTime] isEqualToDate:date], @"DateTime did not match" );
	STAssertTrue( [memory location].latitude == lat, @"Latitude did not match" );
	STAssertTrue( [memory location].longitude == lng, @"Longitude did not match" );
						 
}

- (void) testAddMemory {
	[self helpTestMemoryWithId:1 imageFile:@"photo1.png" audioFile:@"photo1.aiff" date:[NSDate date] lat:112 lng:114.57];
	[self helpTestMemoryWithId:2 imageFile:@"photo1.png" audioFile:@"photo1.aiff" date:[NSDate date] lat:112 lng:114.57];	 
}

- (void) testGenerateFileNameWithExt {
	Memory *memory = [[[Memory alloc] initWithDictionary:[NSDictionary dictionaryWithObjectsAndKeys:
														  [NSNumber numberWithInt:32], kMemoryId,
														  [NSDate date], kDateTime,
														  [NSNumber numberWithDouble:38.5], kLatitude,
														  [NSNumber numberWithDouble:43.7], kLongitude, 
														  nil]] retain];	 
	STAssertTrue ([[memory generateFileNameWithExt:@"png"] isEqualToString:@"32.png"], @"Unexpected generated image file path" );
	STAssertTrue ([[memory generateFileNameWithExt:@"caf"] isEqualToString:@"32.caf"], @"Unexpected generated audio file path" );
	
}



@end
